package indzcraft.ranking;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import indzcraft.loader.IndzCraftLoader;
import indzcraft.loader.Item;

public class Ranking {
	IndzCraftLoader loader;
	
	public Ranking() throws JSONException {
		 loader = new IndzCraftLoader();
		 JSONObject json = loader.getItemDataBattleNet(77948);
		 
		 System.out.println(json.toString(1));
		 
		 		 
		 Item item = new Item();
		 item.setId(json.getInt("id"));
		 JSONArray stats = json.getJSONArray("bonusStats");
		 for (int i = 0;i < stats.length(); i++ )
		 {
			 JSONObject stat = (JSONObject) stats.get(i);
			 if(stat.getInt("stat") == 3){
				 item.setAgi(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 7){
				 item.setSta(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 32){
				 item.setCrit(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 36){
				 item.setHaste(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 31){
				 item.setHit(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 37){
				 item.setExp(stat.getInt("amount"));
			 }
			 else if(stat.getInt("stat") == 49){
				 item.setMastery(stat.getInt("amount"));
			 }
		 }
		
	}
}
